import http from "./http"
import iot from "./iot"
import category from './category'
import product from './product'
import user from './user'

// 获取验证码
const queryCaptchaImage = () => http.get('/captchaImage')

// 用户登录校验
const checkUserLogin = (body) => http.post('/login', body)

// 获取登录者信息「含权限信息」
const queryUserProfile = () => http.get('/getInfo')

// 获取地图标注数据
const queryDeviceAll = () => http.get('/iot/device/all')

// 获取新闻列表的数据
const queryNoticeList = (pageNum = 1,pageSize = 6) =>{
    return http.get('/system/notice/list',{
        params: {
            pageNum,
            pageSize
        }
    })
}

// 获取设备统计的数据
const queryDeviceStatistic = () => http.get('iot/device/statistic')

// 获取饼状图需要的数据
const queryMomitorServer = () => http.get('/monitor/server')

// 获取Mqtt的状态数据
const queryBashBoardStats = () => http.get('/bashBoard/stats')

// 获取个人中心信息
const queryUserInfo = () => http.get('/system/user/profile')

// 修改用户基本信息
const updateUserInfo = (obj)=>{
    return http.put('/system/user/profile',obj)
}

// 修改用户密码
const updateUserPwd = (oldPassword,newPassword)=>{
    return http.put('/system/user/profile/updatePwd',null,{
        params:{
            oldPassword,newPassword
        }
    })
}

// 头像上传
const uploadUserImage = file=>{
    let fm = new FormData()
    fm.append('file',file)
    return http.post('/system/user/profile/avatar',fm)
}


/* // 获取路由列表 */
const queryGetRouters = () => http.get('/getRouters')


/* 暴露API */
const API = {
    iot,
    category,
    product,
    user,
    queryCaptchaImage,
    checkUserLogin,
    queryUserProfile,
    queryDeviceAll,
    queryNoticeList,
    queryDeviceStatistic,
    queryMomitorServer,
    queryBashBoardStats,
    queryUserInfo,
    updateUserInfo,
    updateUserPwd,
    uploadUserImage,
    queryGetRouters
}
export default API




